<template>
  <view class="liquid-glass-nav">
    <view class="nav-container">
      <view 
        v-for="(item, index) in navItems" 
        :key="index"
        class="nav-item" 
        :class="{ active: currentTab === item.key }"
        @click="handleTabClick(item.key)"
      >
        <view class="nav-icon" :class="item.iconClass"></view>
        <text class="nav-text">{{ item.text }}</text>
      </view>
    </view>
  </view>
</template>

<script>
export default {
  name: 'LiquidGlassNav',
  props: {
    // 当前选中的标签
    currentTab: {
      type: String,
      default: 'home'
    },
    // 导航项配置
    navItems: {
      type: Array,
      default: () => [
        {
          key: 'home',
          text: '首页',
          iconClass: 'home-icon'
        },
        {
          key: 'court',
          text: '球场地图',
          iconClass: 'court-icon'
        },
        {
          key: 'mine',
          text: '我的',
          iconClass: 'mine-icon'
        }
      ]
    }
  },
  methods: {
    handleTabClick(tabKey) {
      this.$emit('tab-change', tabKey);
    }
  }
}
</script>

<style lang="scss" scoped>
.liquid-glass-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  background: 
    linear-gradient(135deg, rgba(255, 255, 255, 0.6) 0%, rgba(255, 255, 255, 0.4) 100%),
    url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100" viewBox="0 0 100 100"><rect width="100" height="100" fill="none"/><path d="M0 0L50 50M100 0L50 50M100 100L50 50M0 100L50 50" stroke="rgba(255,255,255,0.2)" stroke-width="0.5"/></svg>');
  background-size: 100% 100%, 4px 4px;
  backdrop-filter: blur(15px);
  -webkit-backdrop-filter: blur(15px);
  border-top: 1px solid rgba(255, 255, 255, 0.4);
  box-shadow: 0 -4rpx 20rpx rgba(0, 0, 0, 0.1);
  z-index: 999;
  padding: 10rpx;
  margin-bottom: env(safe-area-inset-bottom);
}

.nav-container {
  display: flex;
  justify-content: space-around;
  align-items: center;
  // height: 100rpx;
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  height: 100%;
  transition: all 0.3s ease;
  position: relative;
  width: 100rpx;
}

.nav-item.active {
  background: 
    radial-gradient(circle at 30% 30%, rgba(0, 123, 255, 0.39) 0%, rgba(0, 122, 255, 0.15) 50%, transparent 70%),
    linear-gradient(135deg, rgba(0, 122, 255, 0.2) 0%, rgba(86, 204, 242, 0.15) 50%, rgba(0, 122, 255, 0.1) 100%),
    linear-gradient(135deg, rgba(0, 123, 255, 0.658) 0%, rgba(18, 0, 212, 0.517) 100%),
    url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100" viewBox="0 0 100 100"><rect width="100" height="100" fill="none"/><path d="M0 0L50 50M100 0L50 50M100 100L50 50M0 100L50 50" stroke="rgba(255,255,255,0.3)" stroke-width="0.5"/></svg>');
  background-size: 200% 200%, 100% 100%, 100% 100%, 4px 4px;
  background-position: 30% 30%, 0 0, 0 0, 0 0;
  border-radius: 160rpx;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 
    0 0 20rpx rgba(0, 122, 255, 0.3),
    0 5rpx 15rpx rgba(0, 122, 255, 0.2),
    inset 0 0 10rpx rgba(255, 255, 255, 0.3);
  position: relative;
  overflow: hidden;
  animation: activeGlow 3s ease-in-out infinite alternate;
}
.nav-item.active::before {
    content: "";
    pointer-events: none;
    position: absolute;
    z-index: 3;
    left: 0;
    top: 0;
    right: 0;
    bottom: 0;
    border-radius: 400px;
    box-shadow: inset 0 3px 10px rgba(60, 255, 231, 0.6), inset 0 -3px 4px rgba(106, 255, 237, 0.3);
}

.nav-icon {
  width: 48rpx;
  height: 48rpx;
  margin-bottom: 8rpx;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  opacity: 0.7;
  transition: all 0.3s ease;
}

.nav-item.active .nav-icon {
  opacity: 1;
}

.home-icon {
  background-image: url('');
}

.court-icon {
  background-image: url('');
}

.mine-icon {
  background-image: url('');
}

/* 激活状态下的图标样式 */
.nav-item.active .home-icon {
  background-image: url('');
}

.nav-item.active .court-icon {
  background-image: url('');
}

.nav-item.active .mine-icon {
  background-image: url('');
}

.nav-text {
  font-size: 24rpx;
  color: #333;
  font-weight: 500;
  transition: all 0.3s ease;
}

.nav-item.active .nav-text {
  color: #ffffff;
  font-weight: 600;
}
</style>